﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OnlineEducation.Models.OrderViewModels;

namespace OnlineEducation.Helpers
{
    public class StudentHelper
    {
        private StudentHelper() { }
        private static StudentHelper studentHelper;
        public static StudentHelper GetInstance()
        {
            if (studentHelper == null)
            {
                studentHelper = new StudentHelper();
            }
            return studentHelper;
        }
        /// <summary>
        /// 0:未支付，1：支付，2：退款，9 ：取消
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        public string GetBookingStatusDesc(int status)
        {
            string statusDesc = "-";
            if (status == 0)
            {
                statusDesc = "未支付";
            }
            if (status == 1)
            {
                statusDesc = "支付";
            }
            if (status == 2)
            {
                statusDesc = "退款";
            }
            if (status == 9)
            {
                statusDesc = "取消";
            }
            return statusDesc;
        }

        public int? GetEvluationId (int studentId,int planId, List<TeachingEvaluationViewModel> teachingEvaluationViewModels)
        {
            var evalutionInfo = teachingEvaluationViewModels.FirstOrDefault(r => r.TeachPlanId == planId && r.StudentId == studentId);
            if (evalutionInfo != null)
            {
                return evalutionInfo.Id;
            }
            return null;
        }

        public string GetLessonStatus(int status,DateTime start, DateTime end)
        {
            if (status == 0||(status==1 && DateTime.Today<start ))
            {
                return "待授课";
            }
            if (status == 1 && start<= DateTime.Today && end>=DateTime.Today)
            {
                return "授课中";
            }
            if (status == 1 && end < DateTime.Today)
            {
                return "已结课";
            }
            return "取消";
        }
    }
}
